home *** CD-ROM | disk | FTP | other *** search
/ F1 Licenseware / F1 Licenseware - Volume 1.iso / disks / 089a.dms / 089a.adf / TEXTS / CHAPTERS_21-30 / Chapter22.txt < prev    next >
Text File  |  1992-03-06  |  2KB  |  47 lines

  1.                      The Absolute Beginners Guide To Amos
  2.                     -------------------------------------
  3.                               Chapter Twenty Two
  4.                              -------------------
  5. I hope you succeeded in solving the project I set you in chapter 21. 
  6. In case you didn't or would like to check out my solution here it is:
  7.  
  8. REM Example22.Amos (A possible solution)
  9.  
  10. Hide On 
  11. Unpack 10 To 3
  12.  
  13. Repeat 
  14. If Jleft(1) Then Shift Up 1,1,31,1
  15. If Jright(1) Then Shift Down 1,1,31,1
  16. If Fire(1) Then Shift Off 
  17. Until Mouse Key
  18.  
  19. Default 
  20. Edit 
  21.  
  22. First I loaded the starfield routine in Example21.Amos. and edited the code
  23. to appear as above.
  24.  
  25. After unpacking the screen from bank 10 we hit a brand new command 
  26. structure, REPEAT.  This is only half of a command really as it's called a 
  27. REPEAT UNTIL loop. It's just like a DO LOOP structure, remember that?  What 
  28. REPEAT UNTIL does is it REPEATedly executes the instructions between the 
  29. REPEAT and the UNTIL commands. The UNTIL needs a condition attached to it. 
  30. In this case I have decided that the code will be REPEATed UNTIL a MOUSE KEY
  31. has been pressed. I could have put UNTIL INKEY$<>"" (any key press) or 
  32. UNTIL JUP(1) (joystick pushed up) etc.
  33.  
  34. So basically, Amos will be looping between the REPEAT UNTIL instructions
  35. until either a MOUSE KEY is pressed or the JRIGHT, JLEFT or FIRE functions
  36. are true.  If the joystick is pushed to the left we set the SHIFT UP
  37. instruction in action which starts the stars moving. 
  38. The opposite applies for JRIGHT.  I have also added the FIRE button to the 
  39. loop which stops the stars in their tracks. Not bad for a few lines!  
  40.  
  41. I think we have spent long enough on the SHIFT instruction, fun though it is.
  42. Please feel free to experiment further, there are lots of tricks that can be 
  43. done. So get out Dpaint and see what you can do.
  44.  
  45.                               End of Chapter 22
  46.                               ^^^^^^^^^^^^^^^^^
  47.